	//显示图片信息
	function showDiv(id){
			document.getElementById('light').style.display='block';
			document.getElementById('fade').style.display='block';
			$.ajax({
				url:'showImgInfo.action',
				data:'img.id='+id,
				success:function(data){
					var result = $.parseJSON(data);
					var info = $.parseJSON(result);
					var infoHtml = 
					'<form id="upImg" action="upImg.action" method="post" enctype="multipart/form-data">'+
					'<div id="showImgInfo">'+
						'<img src="'+info.imageurl+'" alt="'+info.title+'" id="turnImg" onload="DrawImage(this)"/>'+
					'</div>'+
					'<table style="margin-top: 20px">'+
						'<tr>'+
							'<td>标题：</td>'+
							'<td><input type="text" value="'+info.title+'" id="title" class="required"/></td>'+
							'<td id="titleCheck" style="display:none;font-color:red;">必填</td>'+
						'</tr>'+
						'<tr>'+
							'<td>描述：</td>'+
							'<td><textarea id="description" class="required">'+info.description+'</textarea></td>'+
							'<td id="descCheck" style="display:none;font-color:red;">必填</td>'+
							'</tr>'+
						'<tr>'+
							'<td>链接：</td>'+
							'<td><input type="text" value="'+info.jumpurl+'" id="jumpurl" class="remote url"/></td>'+
						'</tr>'+
					'</table>'+
				'<div style="margin-top: 10px">'+
					'<a href = "javascript:void(0)" onclick = "closeDiv()" style="float: right;">取消</a>'+
					'<a href = "javascript:void(0)" onclick = "upImg('+info.id+')" style="float: right;margin-right:10px">重新上传</a>'+
					'<input type="file" id="a" name="file" style="display:none" />'+
					'<a href = "javascript:void(0)" onclick = "editImgInfo('+info.id+')" style="float: right;margin-right:10px">保存</a>'+
				'</div>'+
				'<form>'
				;
				
				$("#imgInfo").html(infoHtml);
				}
			});
		}
	
	//处理图片
	var flag = false;
	function DrawImage(ImgD) {
		var image = new Image();
		image.src = ImgD.src;
		if (image.width > 0 && image.height > 0) {
			flag = true;
			if (image.width / image.height >= 200 / 200) {
				if (image.height > 200) {
					ImgD.height = 200;
					ImgD.width = (image.width * 200) / image.height;
				} else {
					ImgD.width = image.width;
					ImgD.height = image.height;
				}
			}
		}
	}
	
	function bigImage(ImgD){
		var image = new Image();
		image.src = ImgD.src;
		if (image.width > 280 && image.height > 280) {
			if (image.height / image.width >= 280 / 280) {
				if (image.height > 280) {
					ImgD.width = 280;
					ImgD.height = image.height/(image.width/280);
					ImgD.style.marginTop = -(ImgD.height - 280)/2+'px';
				}else{
					ImgD.width = image.width;
					ImgD.height = image.height;
				}
			}
			if(image.width / image.height >= 280 / 280){
				if(image.width > 280){
					ImgD.style.maxWidth = image.width/(image.height/280);
					var widthB = parseInt(ImgD.style.maxWidth);
					ImgD.style.marginLeft = -(widthB - 280)/2+'px';
				}else{
					ImgD.width = image.width;
					ImgD.height = image.height;
				}
			}
		}
	}
	
	//关闭图片信息框
	function closeDiv(){
		document.getElementById('light').style.display='none';
		document.getElementById('fade').style.display='none';
	}
	
	//修改图片信息
	function editImgInfo(id){
		if($("#turnImg").attr("src")==null||$("#turnImg").attr("src")==""){
			alert("无效图片");
			return;
		}else{
			var turnImg = $("#turnImg").attr("src");
		}
		if($("#title").val().trim()==null||$("#title").val().trim()==""){
			document.getElementById('titleCheck').style.display='block';
			return;
		}else{
			var title = $("#title").val().trim();
		}
		if($("#description").val().trim()==null||$("#description").val().trim()==""){
			document.getElementById('descCheck').style.display='block';
			return;
		}else{
			var description = $("#description").val().trim();
		}
		var jumpurl;
		if($("#jumpurl").val()=="无"){
			jumpurl = "";
		}else{
			jumpurl = $("#jumpurl").val().trim();
		}
		
		$.ajax({
			type:'POST',
			url:'editImgInfo.action',
			data:'img.id='+id+'&img.title='+title+'&img.imageurl='+turnImg+'&img.description='+description+'&img.jumpurl='+jumpurl,
			success:function(data){
				if (data == "\"bingo\""){
					alert("修改成功");
					closeDiv();
					window.location.reload();
				}
			}
		});
	}
	
	//上传图片
	function upImg(id){
		$("#a").click();
		$("#a").change(function(){
			$("#upImg").ajaxSubmit(function(data){
				//alert(data);
				var src = data;
				if(data=="imageError"){
					alert("图片大小不符或格式错误");
					window.location.reload();
				}
				$("#turnImg").attr('src',src);
//				var imgHtml4= '<img id="turnImg" src='+src+' onload="DrawImage(this)"/>';
//				$("#showImgInfo").html(imgHtml4);
				$("#title").val("");
				$("#description").val("");
				$("#jumpurl").val("");
				//alert("修改成功");
			});
			//$("#upImg").submit();
		});
	}